package view.container
{
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	import xm.components.ScrollableContainer;
	import xm.components.table.TD;
	import xm.components.table.TR;
	import xm.components.table.Table;
	import xm.definition.Align;
	
	
	/**
	 * <br> 클래스 설명 : </br>
	 * @author 김정환
	 */	
	public class Scroll18 extends ScrollableContainer
	{
		//-----------------------------------------------------------------------------------
		// public vars
		//-----------------------------------------------------------------------------------
		//-----------------------------------------------------------------------------------
		// protected / internal vars
		//-----------------------------------------------------------------------------------
		//-----------------------------------------------------------------------------------
		// private vars
		//-----------------------------------------------------------------------------------
		private var _table : Table;
		private var _trList : Array;
		private var _tdList : Array;
		
		//-----------------------------------------------------------------------------------
		// public functions
		//-----------------------------------------------------------------------------------
		
		/**
		 * constructor 
		 */	
		public function Scroll18()
		{
			super();
		}
		
		/**
		 * commitProperties
		 */		
		override public function commitProperties():void
		{
			super.commitProperties();
		}
		
		/**
		 * updateDisplayList
		 */		
		override public function updateDisplayList( enforce : Boolean = false ):void
		{
			super.updateDisplayList(enforce);
			this._table.y = scrolledPosY;
		}
		
		//-----------------------------------------------------------------------------------
		// life cycle functions
		//-----------------------------------------------------------------------------------
		
		/**
		 * createChildren
		 */		
		override public function createChildren():void
		{
			super.createChildren();
			this.backgroundAlpha = 0;
			
			var tr : TR, td : TD, tdList : Array, sumHeight : Number, i:int, len:int,
				tableWidth : Number;
				
			// 테이블 너비.
			tableWidth = 439;
			
			_trList = [];
			_tdList = [];
			
			this._table = new Table();
			
			_table.x = 0;
			_table.y = 0;
			_table.borderThickness = [1,1,1,1];
			_table.borderColor = [0xd2d4da, 0xd2d4da, 0xd2d4da, 0xd2d4da];
			addChild( _table );
			
			//1
			tr = _table.makeTR( 100, 0x000000, 1, 0, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( tableWidth, null, 0x718fda, 1, 0, 0xd2d4da, 1, true );
			tdList.push( td );
			td.paddingLeft = 14;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트1" ) );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트2" ) );
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트3" ) );
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트4" ) );
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트5" ) );
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			td.addChild( getField( "테스트6" ) );
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffff00, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			
			
			//2
			tr = _table.makeTR( 100, 0x000000, 1, 1, 0xd2d4da );
			_trList.push( tr );
			
			tdList = [];
			td = tr.makeTD( 129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			
			td = tr.makeTD( tableWidth-129, null, 0xffffff, 1, 1, 0xd2d4da, 1, true );
			td.paddingLeft = 25;
			td.alignVertical = Align.MIDDLE;
			tdList.push( td );
			_tdList.push( tdList );
			
			
			
			
			sumHeight = 0;
			i=0;
			len=_trList.length;
			
			while( i<len )
			{
				sumHeight+= _trList[i].height;
				++i;
			}
			
			_table.viewWidth = tableWidth;
			_table.viewHeight = sumHeight;
			_table.invalidateDisplayList();
			addChild( _table );
			
		}
		
		
		private function getField( str:String ):TextField
		{
			var txt : TextField, tf : TextFormat;
			
			tf = new TextFormat( "돋움", 20, 0x000000, true );
			txt = new TextField();
			txt.defaultTextFormat = tf;
			txt.autoSize = TextFieldAutoSize.LEFT;
			txt.selectable = false;
			txt.multiline = false;
			txt.wordWrap = false;
			txt.text = str;
			
			
			return txt;
		}
		
		/**
		 * createComplete
		 */		
		override public function creationComplete():void
		{
			super.creationComplete();
			
		}
		
		
		/**
		 * add
		 */		
		override public function add():void
		{
			super.add();
		}
		
		
		/**
		 * startAddTransition : add 완료 후 transition 이 있으면 화면전환효과를 실행한다.
		 */		
		override public function startAddTransition():void
		{
			super.startAddTransition();
		}
		
		/**
		 * startAddTransition 완료.
		 */		
		override public function endAddTransition():void
		{
			super.endAddTransition();
		}
		
		
		/**
		 * startRemoveTransition : remove 하기 전 transition 이 있으면 화면전환효과를 실행한다.
		 */		
		override public function startRemoveTransition():void
		{
			super.startRemoveTransition();
		}
		
		
		/**
		 * startRemoveTransition 완료.
		 */		
		override public function endRemoveTransition():void
		{
			super.endRemoveTransition();
		}
		
		/**
		 * remove
		 */		
		override public function remove():void
		{
			super.remove();
		}
		
		
		/**
		 * destroy
		 */		
		override public function destroy():void
		{
			super.destroy();
			
		}
		
		//-----------------------------------------------------------------------------------
		// setter / getter
		//-----------------------------------------------------------------------------------
		
		/**
		 * @return 
		 */		
		override public function get height():Number
		{
			return ( _table ) ? _table.height : 0;
		}
		
		//-----------------------------------------------------------------------------------
		// protected functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// internal functions
		//-----------------------------------------------------------------------------------
		
		
		
		
		//-----------------------------------------------------------------------------------
		// private functions
		//-----------------------------------------------------------------------------------
		
		
		
		//-----------------------------------------------------------------------------------
		// event handler
		//-----------------------------------------------------------------------------------
		
		
		
		
		
		
		
		
		
	}
}